package com.jiarong.mapper;

import com.jiarong.domain.Role;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author 加绒
 * @date 2021/10/29 9:58
 */
public interface RoleMapper {
    /**
     * 根据用户id查询用户
     *
     * @param userId 用户id
     * @return 角色信息集合
     */
    @Select("select * from role r, user_role ur where r.role_id = ur.role_id and ur.user_id = #{userId}")
    @Results({
            @Result(column = "role_id", property = "roleId"),
            @Result(column = "role_name", property = "roleName"),
    })
    List<Role> selectRoleByUserId(Integer userId);
}
